home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / database / msgobj10.zip / SMALLPOS.CPP < prev   
C/C++ Source or Header  |  1993-03-13  |  2KB  |  94 lines

  1. // SMALLPOS.CPP: a little message sender
  2.  
  3. #include <conio.h>
  4. #include <ctype.h>
  5. #include <fstream.h>
  6. #include <iostream.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #define MAIN
  11. #include "pipbase.h"
  12. #include "pipreply.h"
  13. #include "pipext.h"
  14. #include "config.h"
  15. #include "msgobj.h"
  16.  
  17.  
  18. void main(int argc,char *argv[])
  19. {
  20.   FILE *f;
  21.   int msgnum,k,i;
  22.   char fn[72],*p;
  23.   char huge*o;
  24.   if(argc!=9 && argc!=5)
  25.     {
  26.       cerr << "usage: SMALLPOST area# filename.ext \"destname\" \"subject\" zone net node point\n";
  27.       exit(1);
  28.     }
  29.   // reads PIP* 2.00 configuration files
  30.   f=fopen("NodeInfo.Cfg","rb");
  31.   if(!f)
  32.     {
  33.       cerr << "I cannot find NodeInfo.Cfg\nplease create it with PIP SET\n";
  34.       exit(1);
  35.     }
  36.   fread(&cfg,sizeof cfg,1,f);
  37.   fclose(f);
  38.   sprintf(fn,"%sOrigins.Pip",cfg.pipdir); f=fopen(fn,"rb");
  39.   if (f==NULL)
  40.     {
  41.       cerr << "I cannot locate the PipBase files; please check for " << fn << "\n";
  42.       exit(1);
  43.     }
  44.   o=(char*)malloc(60*256);
  45.   if(o==NULL)
  46.     {
  47.       cerr << "Not enough memory!\n";
  48.       exit(1);
  49.     }
  50.   fread(o,60*256,1,f); fclose(f);
  51.   for(i=0; i!=256;i++) origins[i]=o+60*i;
  52.   // allocate MessageObject
  53.   message_frame msg;
  54.   // operations to be done if you want to send a message:
  55.   // set message area
  56.   msg.area=atoi(argv[1]);
  57.   // allocate text
  58.   if(msg.allocate_text(BUFSIZE))
  59.     {
  60.       cerr << "Allocation error\n";
  61.       exit(1);
  62.     }
  63.   // readfile is only an useful function, generally, you'll have to place
  64.   // your message text in the buffer pointed by msg.text
  65.   if(msg.readfile((unsigned char huge*)msg.text,argv[2]))
  66.     {
  67.       cerr << "input file not found!\n";
  68.       exit(1);
  69.     }
  70.   // load header informations
  71.   strcpy(msg.from,cfg.usernames[0]);
  72.   strcpy(msg.to,argv[3]);
  73.   strcpy(msg.subject,argv[4]);
  74.   *msg.fromaddr.uucp=0;
  75.   *msg.toaddr.uucp=0;
  76.   strcpy(msg.fromaddr.domain,cfg.address[0].domain);
  77.   msg.fromaddr.zone=cfg.address[0].zone;
  78.   msg.fromaddr.net=cfg.address[0].net;
  79.   msg.fromaddr.node=cfg.address[0].node;
  80.   msg.fromaddr.point=cfg.address[0].point;
  81.   strcpy(msg.toaddr.domain,cfg.address[0].domain);
  82.   if(argc==9)
  83.     {
  84.       msg.toaddr.zone=atoi(argv[5]);
  85.       msg.toaddr.net=atoi(argv[6]);
  86.       msg.toaddr.node=atoi(argv[7]);
  87.       msg.toaddr.point=atoi(argv[8]);
  88.     }
  89.   else
  90.     msg.toaddr=msg.fromaddr;
  91.   // finally, call msg.post();
  92.   msg.post();
  93. }
  94.